package com.zcn.io.web.controller;

import com.zcn.io.common.entity.TransferPhone;
import com.zcn.io.common.pojo.CommonResult;
import com.zcn.io.web.api.query.OrderMainQuery;
import com.zcn.io.web.api.vo.PhoneCardVo;
import com.zcn.io.web.api.vo.TransferPhoneVo;
import com.zcn.io.web.service.TransferPhoneService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @desc:
 * @author: 202438 邱建伟
 * @date: 2024/9/27 12:30
 * @Copyright (c) 2024, 江苏金恒信息科技股份有限公司
 */
@RequestMapping("/transferPhone")
@RestController
public class TransferPhoneController {

    @Autowired
    private TransferPhoneService transferPhoneService;

    @GetMapping("/list")
    public CommonResult<List<TransferPhoneVo>> list(TransferPhone transferPhone){
        return CommonResult.success(transferPhoneService.list(transferPhone));
    }

    @PostMapping("/save")
    public CommonResult save(@RequestBody TransferPhone transferPhone){
        transferPhoneService.save(transferPhone);
        return CommonResult.success("保存成功");
    }

    @PostMapping("/update")
//    @PreAuthorize("hasAuthority('super_man')")
    public CommonResult update(@RequestBody TransferPhone transferPhone){
        transferPhoneService.update(transferPhone);
        return CommonResult.success("更新成功");
    }

    @DeleteMapping("/delete")
    @PreAuthorize("hasAuthority('super_man')")
    public CommonResult delete(@RequestParam String id){
        transferPhoneService.delete(id);
        return CommonResult.success("删除成功");
    }

    @GetMapping("/dict")
    public CommonResult dict(){
        return CommonResult.success(transferPhoneService.dict());
    }

    @GetMapping("/getPhoneCardList")
    public CommonResult<List<PhoneCardVo>> getPhoneCardList(OrderMainQuery orderMain) {
        return CommonResult.success(transferPhoneService.getPhoneCardListBase(orderMain));
    }

    @GetMapping("/getPhoneCardListPlus")
    public CommonResult<List<PhoneCardVo>> getPhoneCardListPlus(OrderMainQuery orderMain) {
        return CommonResult.success(transferPhoneService.getPhoneCardListPlus(orderMain));
    }

    @GetMapping("/getPhoneCardListWarn")
    public CommonResult<List<PhoneCardVo>> getPhoneCardListWarn(OrderMainQuery orderMain) {
        return CommonResult.success(transferPhoneService.getPhoneCardListWarn(orderMain));
    }


    @GetMapping("/getPhoneUseMemo")
    public CommonResult<String> getPhoneUseMemo(){
        return CommonResult.success(transferPhoneService.getPhoneUseMemo());
    }


    @PostMapping("/updatePhoneUseMemo")
    public CommonResult updatePhoneUseMemo(@RequestBody TransferPhone phoneUseMemo){
        transferPhoneService.updatePhoneUseMemo(phoneUseMemo);
        return CommonResult.success("更新成功");
    }
}
